from rest_framework import serializers
from orders.models import OrderInfo,OrderGoods
from goods.models import SKU

class SKUSerializer(serializers.ModelSerializer):
    '''SKU商品信息序列化器'''
    class Meta:
        model=SKU
        fields='__all__'

class OrderGoodsSerializer(serializers.ModelSerializer):
    '''订单商品信息序列化器'''
    sku = SKUSerializer()
    class Meta:
        model=OrderGoods
        fields='__all__'



class OrderSerializer(serializers.ModelSerializer):
    '''订单基本信息序列化器'''
    # 关联嵌套返回 用户表数据和订单商品表数据
    skus = OrderGoodsSerializer(many=True)
    class Meta:
        model=OrderInfo
        fields='__all__'



